﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;


using PowerCreator.LMS.Paper.Entiry;
using PowerCreator.LMS.Web.Paper;
using PowerCreator.LMS.Web.Question;
using PowerCreator.LMS.Web.Course;
using PowerCreator.LMS.ViewQuery;

public partial class sysadmin_PaperResearchManager_SubjectivityStatistical : PowerCreator.LMS.Web.Base.WebBasePage
{

    ManagerPaper objManagerPaper = new ManagerPaper();
    Course objCourse = new Course();
    ManagerQuestion objManagerQuestion = new ManagerQuestion();
    ViewQuery objViewQuery = new ViewQuery();

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!GetRole(Role.ManagerPaper))
        //{
        //    Script.ShowAndHistory("您没有管理试卷的权限!", -1);
        //    return;
        //}
        if (!IsPostBack)
        {
            ViewState["QuestionID"] = Request.QueryString["qID"].ToString();
            ViewState["PaperID"] = Request.QueryString["pID"].ToString();
            string search = GetSearch();
            BinderPager(search);
            BinderGV(search, 1);
            //InitPage();
        }
    }
    private string GetSearch()
    {
        StringBuilder str_search = new StringBuilder();
        //str_search.Append(" 1=1 and PaperBuildState=1  ");
        //str_search.Append(" 1=1 ");

        str_search.Append(" FKPRUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPRUanswerQuestionID=" + ViewState["QuestionID"].ToString());

        //if (dpdlst_PaperState.SelectedValue != "-1")
        //{
        //    str_search.Append(" and PaperBuildState=" + dpdlst_PaperState.SelectedValue);
        //}

        //if (txtPaperName.Text.Trim() != "")
        //{
        //    str_search.Append(" and PaperName like '%" + txtPaperName.Text + "%'");
        //}


        return str_search.ToString();
    }
    private void BinderPager(string search)
    {
        AspNetPager1.RecordCount = objManagerPaper.CountPaperResearch(search);
        AspNetPager1.PageSize = LMSPageSize;
    }

    private void BinderGV(string search, int pageIndex)
    {
        DataTable dt = new DataTable();
        dt = objManagerPaper.QueryPaperResearchUserAnswer(search, LMSPageSize, pageIndex);
        dt.Columns.Add("Index");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["Index"] = (pageIndex - 1) * 10 + i + 1;
        }
        gvPaperList.DataSource = dt;
        gvPaperList.DataBind();
    }

    protected void gvPaperList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("bgColor", "#F7FAFF");
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FAEDB8'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F7FAFF'");
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }
}
